package com.itlong.cloud.app.resource;

import com.itlong.cloud.POJO.DTO.app.engineer.AppEngineerDevicesDTO;
import com.itlong.cloud.POJO.DTO.app.engineer.AppEngineerThresholdDTO;
import com.itlong.cloud.POJO.VO.app.engineer.AppEngineerDevicesVO;
import com.itlong.cloud.POJO.VO.app.engineer.AppEngineerDoorDevicesVO;
import com.itlong.cloud.POJO.VO.app.engineer.AppEngineerFloorDevicesVO;
import com.itlong.cloud.POJO.VO.app.engineer.AppEngineerQrCodeDeviceVO;
import com.itlong.cloud.app.service.IAppEngineerDeviceService;
import com.itlong.cloud.equip.app.IAppEngineerDeviceServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <desc>
 *      工程版APP设备信息业务处理暴露接口实现类。
 * <desc/>
 *
 * @createDate 2017/11/8.
 */
@RestController
public class AppEngineerDeviceServiceResource implements IAppEngineerDeviceServiceClient {

    @Autowired
    IAppEngineerDeviceService iAppEngineerDeviceService;

    /**
     * <desc>
     *      获取用户门禁设备列表
     * </desc>
     *
     * @param userId 用户Id
     * @param projectId 项目Id
     * @return
     * @author shengen.T
     * @createDate 2017/11/8
     */
    @Override
    @RequestMapping(path = "/engineer/getDoorDevices",method = RequestMethod.POST)
    public List<AppEngineerDoorDevicesVO> getDoorDevices(@RequestParam("userId")String userId, @RequestParam("projectId")String projectId) throws Exception{
        List<AppEngineerDoorDevicesVO> doorDevicesVOList = iAppEngineerDeviceService.getDoorDevices(userId,projectId);
        return doorDevicesVOList;
    }

    /**
     * <desc>
     *      获取用户电梯设备列表
     * </desc>
     *
     * @param userId 用户Id
     * @param projectId 项目Id
     * @return
     * @author shengen.T
     * @createDate 2017/11/8
     */
    @Override
    @RequestMapping(path = "/engineer/getFloorDevices",method = RequestMethod.POST)
    public List<AppEngineerFloorDevicesVO> getFloorDevices(@RequestParam("userId")String userId, @RequestParam("projectId")String projectId) throws Exception{
        List<AppEngineerFloorDevicesVO> floorDevicesVOList = iAppEngineerDeviceService.getFloorDevices(userId,projectId);
        return floorDevicesVOList;
    }

    /**
     * <desc>
     *      获取设备机号。
     * <desc/>
     *
     * @param devicesDTO 设备请求参数
     * @return
     * @author shengen.T
     * @createDate 2017/11/8
     */
    @Override
    @RequestMapping(path = "/engineer/getDeviceId",method = RequestMethod.POST)
    public List<AppEngineerDevicesVO> getDeviceId(@RequestBody AppEngineerDevicesDTO devicesDTO) throws Exception{
        return iAppEngineerDeviceService.getDeviceId(devicesDTO);
    }

    /**
     * <desc>
     *      上传阈值。
     * <desc/>
     *
     * @param thresholdDTO 请求参数
     * @return
     * @author shengen.T
     * @createDate 2017/11/9
     */
    @RequestMapping(path = "/engineer/uploadData",method = RequestMethod.POST)
    public Integer uploadData(@RequestBody AppEngineerThresholdDTO thresholdDTO) throws Exception{
        return iAppEngineerDeviceService.uploadData(thresholdDTO);
    }

    /**
     * <desc>
     *      获取二维码绑定的设备信息
     * </desc>
     *
     * @return 二维码绑定的设备信息
     * @author wangzhi
     * @createDate 2020/02/26
     */
    @Override
    @RequestMapping(path = "/engineer/getDeviceByQrCode", method = RequestMethod.POST)
    public AppEngineerQrCodeDeviceVO getDeviceByQrCode(@RequestParam("qrCodeContent") String qrCodeContent) throws Exception {
        return iAppEngineerDeviceService.getDeviceByQrCode(qrCodeContent);
    }

    /**
     * <desc>
     *      绑定设备与二维码
     * </desc>
     *
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2020/02/26
     */
    @Override
    @RequestMapping(path = "/engineer/bindingDeviceQrCode", method = RequestMethod.POST)
    public Integer bindingDeviceQrCode(@RequestParam("qrCodeContent") String qrCodeContent,
                                       @RequestParam("projectId") String projectId,
                                       @RequestParam("deviceType") String deviceType,
                                       @RequestParam(value = "sedanPlace", required = false) String sedanPlace,
                                       @RequestParam("deviceUnique") String deviceUnique,
                                       @RequestParam(value = "floor", required = false) String floor,
                                       @RequestParam("userId") String userId) throws Exception {
        return iAppEngineerDeviceService.bindingDeviceQrCode(qrCodeContent, projectId, deviceType, sedanPlace, deviceUnique, floor, userId);
    }

    /**
     * <desc>
     *      获取电梯设备的楼层
     * </desc>
     *
     * @return 电梯设备的楼层列表
     * @author wangzhi
     * @createDate 2020/03/11
     */
    @Override
    @RequestMapping(path = "/engineer/getDeviceFloors", method = RequestMethod.POST)
    public List<String> getDeviceFloors(@RequestParam("projectId") String projectId, @RequestParam("deviceUnique") String deviceUnique) throws Exception {
        return iAppEngineerDeviceService.getDeviceFloors(projectId, deviceUnique);
    }
}
